Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add OrderBy param to subscription list #842

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dagbay-rh
Copy link
Contributor

@dagbay-rh dagbay-rh commented Sep 21, 2023

Summary

  • add OrderBy param to the Subscriptions resource

Ticket

Why

Current State

When querying accounts management service, we can use the orderBy param to order the result set.

ocm-sdk provides a .Order() method to set this parameter when querying for subscriptions: https://github.com/openshift-online/ocm-sdk-go/blob/main/accountsmgmt/v1/subscriptions_client.go#L169-L186. So we can use this method like so to order on "status":

	result, err := AMSclient.AccountsMgmt().V1().Subscriptions().List().
		Search(query string).
		Order("status").
		Size(10).
		Page(1).
                Send()

However, when the request is sent, the sdk sets order on the request to AMS, not orderBy. See here: https://github.com/openshift-online/ocm-sdk-go/blob/main/accountsmgmt/v1/subscriptions_client.go#L247-L249
So this param gets ignored by AMS and the result set of the request is not ordered like intended.

In ocm cli terms:

ocm get subscriptions -p size=10 -p page=1 -p search="....." -p order="status"

is the request that gets sent by ocm-sdk now, which does not sort the result set

Proposed Change

We would provide an OrderBy method that is used like this (added a new method to not break existing functionality):

	result, err := AMSclient.AccountsMgmt().V1().Subscriptions().List().
		Search(query string).
		OrderBy("status").
		Size(10).
		Page(1).
                Send()

which would generate the following request in ocm cli terms:

ocm get subscriptions -p size=10 -p page=1 -p search="....." -p orderBy="status"

AMS apispec detailing the orderBy param: https://api.openshift.com/?urls.primaryName=Accounts%20management%20service#/default/get_api_accounts_mgmt_v1_subscriptions
image

Current Workaround

Right now we can get around this by setting the orderBy param explicitly like so:

	result, err := AMSclient.AccountsMgmt().V1().Subscriptions().List().
		Search(query string).
		Parameter("orderBy", "status").
		Size(10).
		Page(1).
                Send()

Testing

  • generated new sdk locally via make model_version=HEAD model_url=../ocm-api-model generate
  • verified sdk appends the orderBy param to the generated request to AMS

@dagbay-rh dagbay-rh marked this pull request as draft September 26, 2023 19:07
@@ -55,6 +55,10 @@ resource Subscriptions {
//
// If the parameter isn't provided, or if the value is empty, then the order of the
// results is undefined.
@http(name = "orderBy")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this was required to build the http param correctly, without it the param was being generated in pascal case: OrderBy

@renan-campos
Copy link
Collaborator

This is an old PR, I've asked the AMS team to take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants